/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SysAguas.Testes;

import SysAguas.dao.DAOGenerico;
import SysAguas.modelo.Pousada;
import SysAguas.modelo.Reserva;
import java.util.List;

/**
 *
 * @author Heitor
 */
public class PousadaTeste {

    public static void main(String[] args) {

       Pousada pou = new Pousada();
        DAOGenerico dao = new DAOGenerico();
/* 
        /*cadastra a pousada****************
        pou.setNome("SysAguas");

        dao.cadastrar(pou);
        //**/



//* recuperar a pausada********************
     /*   Pousada p = dao.consultarPorChave(Pousada.class, 4);


      //  List<Reserva> listaR = dao.getLista(Reserva.class, "select r from Reserva r");

        /*
        dao.abreConexao();
        dao.getEntityManeger().getTransaction().begin();
        
        System.out.println(listaR.size());
        for (int i = 0; i < listaR.size(); i++) {
        System.out.println("ID da "+(i+1)+"º reserva  ="+listaR.get(i).getId());

        listaR.get(i).setPousadaR(p);
        p.addReserva(listaR.get(i));
        }


//atualizar********************
        dao.atualizar(p);
        /**/



//remover***********************
/*
        dao.abreConexao();
        dao.getEntityManeger().getTransaction().begin();
        for (int i = 0; i < listaR.size(); i++) {


            listaR.get(i).removePousada(p);
            
        }
        p.removeReserva(listaR);
        for (int i = 0; i < listaR.size(); i++) {
            dao.getEntityManeger().merge(listaR.get(i));

        }
       
   

        dao.remover(p);



        /**/
    }
}
